import { Component ,Input} from '@angular/core';// 引入具体的值
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import{Hero} from '../heros/Hrtest.module';


// 详情页的一个组件

/**
 * Generated class for the HeroDetailPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-hero-detail',
  // templateUrl: 'hero-detail.html',
  template:`
  <div *ngIf="hero">
      <h2>{{hero.name}} details!</h2>
      <div><label>id: </label>{{hero.id}}</div>
      <div>
        <label>name: </label>
        <input [(ngModel)]="hero.name" placeholder="name"/>
      </div>
    </div>
  `
})

//id 
export class HeroDetailPage {
  id:number;
  //hero: Hero; 
  @Input() hero: Hero; //这个hero的值继承父组件上的值
  constructor(public navCtrl: NavController, public navParams: NavParams) {
        this.id = navParams.get('id');
        console.log('nav param id',this.id);
    // this.id = navParams.get('item');
   // this.id = NavParams.get("id");  params 和navparam的区别。
  //  this.id = params.get("id");
   // console.log('当前id',this.id);
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad HeroDetailPage');
  }

}
